
from selenium import webdriver

# 设置浏览器驱动路径
from selenium.webdriver.common.by import By
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC


driver = webdriver.Chrome()
# 最大化浏览器窗口
driver.maximize_window()
# 打开网址
url = "https://www.baidu.com/"  # 替换为你要打开的网址
driver.get(url)


wait = WebDriverWait(driver, 10)
# 登录按钮
login_button = wait.until(EC.element_to_be_clickable((By.XPATH, '//a[@class="s-top-login-btn c-btn c-btn-primary c-btn-mini lb"]')))
login_button.click()
input("1登录页面已经打开，请在页面操作，完成后按Enter键继续...")

# 查找并点击按钮
# login_button = driver.find_element_by_xpath('//a[@class="product-button02"]')  # 使用XPath定位按钮
# login_button = driver.find_element(by='css selector', value='.product-button a')
# 文本输入
input_box = wait.until(EC.element_to_be_clickable((By.ID, 'kw')))
input_box.clear()
user_input = input("2搜索框，请输入要搜索的内容，完成后按Enter键继续...")
input_box.send_keys(user_input)

# 搜索按钮
login_button = wait.until(EC.element_to_be_clickable((By.ID, 'su')))
login_button.click()
input("3搜索已经完成，完成后按Enter键继续...")

# 立即下单
# login_button = wait.until(EC.element_to_be_clickable((By.XPATH, '//a[@class="product-button02 product-agreement-style"]')))
# login_button = wait.until(EC.presence_of_element_located((By.XPATH, '//span[@class="product-button02 product-agreement-style"]')))
# login_button.click()
# #提交订单
# login_button = wait.until(EC.element_to_be_clickable((By.XPATH, '//a[@class="order-submit-btn"]')))
# login_button.click()
# #确认支付
# confirm_pay_button = wait.until(EC.element_to_be_clickable((By.XPATH, '//button[@class="confirmPay pull-right"]')))
# confirm_pay_button.click()


# 关闭浏览器
driver.quit()